#!/usr/bin/env bash
# ******************************************************************************
# @file     submodule.sh
# @brief    对文件的简要说明
# @details  对文件的详细说明
# @author   jcai
# @date     2024-07-13 00:09:09
# @copyright Copyright &copy; 2024 wy1107412334@163.com All rights reserved
# @version  v0.0.1
#
# \n Email:  wy1107412334@163.com
# \n Blog:   None
# \n Github: https://github.com/wy1107412334
# \n Gitee:  https://gitee.com/git.git1107412334.com
#
# ******************************************************************************
# @note
# None.
# ******************************************************************************
# @attention
# None.
# ******************************************************************************
#@verbatim
#@endverbatim
# ******************************************************************************
# @par 历史记录
# jcai, 2024-07-13 00:09:09
# - 首次编写
#
#<center>Copyright &copy; 2024 wy1107412334@163.com All rights reserved</center>
# ******************************************************************************

set -x

function submodule_init()
{
    cd ${CurrentScriptPath}
    git submodule init
    git submodule update --recursive


    cd ${CurrentScriptPath}/modules/FileSystem
    git submodule init
    git submodule update --recursive

    cd ${CurrentScriptPath}/modules/FileSystem/modules/flashEmu
    git submodule init
    git submodule update --recursive
}

function submodule_update()
{
    cd ${CurrentScriptPath}/modules/lvgl
    git pull --rebase


    cd ${CurrentScriptPath}/modules/FileSystem/modules/flashEmu
    git pull --rebase

    cd ${CurrentScriptPath}/modules/FileSystem
    git pull --rebase
}


git_version=$(git --version)
if [[ -z ${git_version} ]]; then
    echo "does not exist git command"
    exit 1
fi

CurrentScriptPath=$(dirname $(readlink -f $0))
oldpwd=$(pwd)



if [ $@ -lt 1]; then
    echo "Usage:"
    echo "$0 <init | update>"
    exit 1
fi

case $1 in
    init)
        submodule_init
    ;;
    update)
        submodule_update
    ;;
    *)
        echo "Unknown command '$1'"
        echo "Usage:"
        echo "$0 <init | update>"
        exit 1
    ;;
esac

cd ${oldpwd}


# ********************************** END OF FILE *******************************

